/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_UserInfo.mx_BaseCard {
    // UserInfo has a circular image at the top so it fits between the back & close buttons
    padding-top: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    font-size: $font-12px;

    .mx_UserInfo_cancel {
        cursor: pointer;
        position: absolute;
        top: 0;
        border-radius: 4px;
        background-color: $dark-panel-bg-color;
        margin: 9px;
        z-index: 1; // render on top of the right panel

        div {
            height: 16px;
            width: 16px;
            padding: 4px;
            mask-image: url('$(res)/img/minimise.svg');
            mask-repeat: no-repeat;
            mask-position: 7px center;
            background-color: $header-panel-text-primary-color;
        }
    }

    h2 {
        font-size: $font-18px;
        font-weight: 600;
        margin: 18px 0 0 0;
    }

    .mx_UserInfo_container {
        padding: 8px 16px;
    }

    .mx_UserInfo_separator {
        border-bottom: 1px solid rgba($primary-content, .1);
    }

    .mx_UserInfo_memberDetailsContainer {
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 8px;
    }

    .mx_RoomTile_nameContainer {
        width: 154px;
    }

    .mx_RoomTile_badge {
        display: none;
    }

    .mx_RoomTile_name {
        width: 160px;
    }

    .mx_UserInfo_avatar {
        margin: 24px 32px 0 32px;
    }

    .mx_UserInfo_avatar > div {
        max-width: 30vh;
        margin: 0 auto;
        transition: 0.5s;
    }

    .mx_UserInfo_avatar > div > div {
        /* use padding-top instead of height to make this element square,
        as the % in padding is a % of the width (including margin,
        that's why we had to put the margin to center on a parent div),
        and not a % of the parent height. */
        padding-top: 100%;
        position: relative;
    }

    .mx_UserInfo_avatar > div > div * {
        border-radius: 100%;
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
    }

    .mx_UserInfo_avatar .mx_BaseAvatar_initial {
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: center;

        // override the calculated sizes so that the letter isn't HUGE
        font-size: 6rem !important;
        width: 100% !important;
        transition: font-size 0.5s;
    }

    .mx_UserInfo_avatar .mx_BaseAvatar.mx_BaseAvatar_image {
        cursor: zoom-in;
    }

    h3 {
        text-transform: uppercase;
        color: $tertiary-content;
        font-weight: 600;
        font-size: $font-12px;
        margin: 4px 0;
    }

    p {
        margin: 5px 0;
    }

    .mx_UserInfo_profile {
        text-align: center;

        h2 {
            display: flex;
            font-size: $font-18px;
            line-height: $font-25px;
            flex: 1;
            justify-content: center;

            span {
                // limit to 2 lines, show an ellipsis if it overflows
                // this looks webkit specific but is supported by Firefox 68+
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;

                overflow: hidden;
                word-break: break-all;
                text-overflow: ellipsis;
            }

            .mx_E2EIcon {
                margin-top: 3px; // visual vertical centering to the top line of text
                margin-right: 4px; // margin from displyname
                min-width: 18px; // convince flexbox to not collapse it
            }
        }

        .mx_UserInfo_profileStatus {
            margin-top: 12px;
        }
    }

    .mx_UserInfo_memberDetails .mx_UserInfo_profileField {
        display: flex;
        justify-content: center;
        align-items: center;

        margin: 6px 0;

        .mx_UserInfo_roleDescription {
            display: flex;
            justify-content: center;
            align-items: center;
            // try to make it the same height as the dropdown
            margin: 11px 0 12px 0;
        }

        .mx_Field {
            margin: 0;
        }
    }

    .mx_UserInfo_field {
        cursor: pointer;
        color: $accent;
        line-height: $font-16px;
        margin: 8px 0;

        &.mx_UserInfo_destructive {
            color: $alert;
        }
    }

    .mx_UserInfo_statusMessage {
        font-size: $font-11px;
        opacity: 0.5;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: clip;
    }

    .mx_AutoHideScrollbar {
        flex: 1 1 0;
    }

    .mx_UserInfo_container:not(.mx_UserInfo_separator) {
        padding-top: 16px;
        padding-bottom: 0;

        > :not(h3) {
            margin-left: 8px;
        }
    }

    .mx_UserInfo_devices {
        .mx_UserInfo_device {
            display: flex;
            margin: 8px 0;

            &.mx_UserInfo_device_verified {
                .mx_UserInfo_device_trusted {
                    color: $accent;
                }
            }
            &.mx_UserInfo_device_unverified {
                .mx_UserInfo_device_trusted {
                    color: $alert;
                }
            }

            .mx_UserInfo_device_name {
                flex: 1;
                margin-right: 5px;
                word-break: break-word;
            }
        }

        // both for icon in expand button and device item
        .mx_E2EIcon {
            // don't squeeze
            flex: 0 0 auto;
            margin: 2px 5px 0 0;
            width: 12px;
            height: 12px;
        }

        .mx_UserInfo_expand {
            display: flex;
            margin-top: 11px;
        }
    }

    .mx_AccessibleButton.mx_AccessibleButton_hasKind {
        padding: 8px 18px;
    }
}

.mx_UserInfo.mx_UserInfo_smallAvatar {
    .mx_UserInfo_avatar > div {
        max-width: 72px;
        margin: 0 auto;
    }

    .mx_UserInfo_avatar .mx_BaseAvatar_initial {
        font-size: 40px !important; // override the other override because here the avatar is smaller
    }
}
